{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0942c28e-24f7-4cb5-9477-6cbd44f0872f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a8e209ee-78a5-4c82-90bc-55eebb87fbcd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<re.Match object; span=(0, 9), match='010-12345'>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re.match(r'^\\d{3}\\-\\d{3,8}$', '010-12345')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "60ea8a23-7e0d-4ed2-bc71-ab1dc7376ab5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['a', 'b', 'c']"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re.split(r'\\s+', 'a b   c')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "ce625c00-4bb8-41ad-aecf-a7dd905633eb",
   "metadata": {},
   "outputs": [],
   "source": [
    " m =re.match(r'^(\\d{3})-(\\d{3,8})$', '010-12345')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "110fe5c7-ba26-4e38-8a8d-ae8d02e38129",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'010-12345'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "m.group(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "95545591-e2b0-4311-a2f1-c1cb792ac157",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'010'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "m.group(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "6d071f03-77ad-4e42-b0c4-0f5428daf58e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('102300',)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re.match(r'^(\\d+)', '102300').groups()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "3ceb0c38-31cf-4652-8412-c7ed68b24db9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('1',)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re.match(r'^(\\d+?)', '102300').groups()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "acf69a96-6042-464c-a591-f8dcc605f4aa",
   "metadata": {},
   "outputs": [],
   "source": [
    " re_telephone = re.compile(r'^(\\d{3})-(\\d{3,8})$')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e4502913-b31c-45c9-a755-4bbab6bf09d2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('010', '12345')"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "re_telephone.match('010-12345').groups()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3d4fe305-acd0-45b4-9636-09100266da2e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.21"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
